﻿using System;
using System.ComponentModel;
using System.Web.UI;
using umbraco.cms.businesslogic.media;
using umbraco.cms.businesslogic.datatype;
using umbraco.cms.businesslogic.propertytype;
using umbraco.BusinessLogic;


namespace UmbracoAdvert.Tools
{


    public partial class MediaInstaller : UserControl
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            this.pnlInstaller.Visible = true;
            this.pnlSucces.Visible = false;
            this.pnlError.Visible = false;

        }
        protected void Install(object sender, EventArgs e)
        {
            this.pnlInstaller.Visible = false;
            //add the Flash Media

            MediaType mtF = MediaType.MakeNew(User.GetCurrent(), "Flash Media"); ;
            PropertyType ptf1 = mtF.AddPropertyType(DataTypeDefinition.GetByDataTypeId(Guid.Parse("C6BAC0DD-4AB9-45B1-8E30-E4B619EE5DA3")), "ad_integratedCode", "Integrated Code");



            //PropertyType ptf2 = mtF.AddPropertyType(DataTypeDefinition.GetByDataTypeId(new Guid("5032A6E6-69E3-491D-BB28-CD31CD11086C")), "ad_thumbnailImage", "Thumbnail Image");
            //PropertyType ptf3 = mtF.AddPropertyType(DataTypeDefinition.GetByDataTypeId(new Guid("5032A6E6-69E3-491D-BB28-CD31CD11086C")), "ad_FlashFile", "Flash File");
            //PropertyType ptf4 = mtF.AddPropertyType(DataTypeDefinition.GetByDataTypeId(new Guid("EC15C1E5-9D90-422A-AA52-4F7622C63BEA")), "ad_description", "Description");

            //PropertyType ptf1 = mtF.AddPropertyType(DataTypeDefinition.GetDataTypeDefinition(new Guid("67DB8357-EF57-493E-91AC-936D305E0F2A")), "ad_integratedCode", "Integrated Code");
            //PropertyType ptf2 = mtF.AddPropertyType(DataTypeDefinition.GetDataTypeDefinition(new Guid("5032A6E6-69E3-491D-BB28-CD31CD11086C")), "ad_thumbnailImage", "Thumbnail Image");
            //PropertyType ptf3 = mtF.AddPropertyType(DataTypeDefinition.GetDataTypeDefinition(new Guid("5032A6E6-69E3-491D-BB28-CD31CD11086C")), "ad_FlashFile", "Flash File");
            //PropertyType ptf4 = mtF.AddPropertyType(DataTypeDefinition.GetDataTypeDefinition(new Guid("EC15C1E5-9D90-422A-AA52-4F7622C63BEA")), "ad_description", "Description");

            int tabF = mtF.AddVirtualTab("Media");
            mtF.SetTabOnPropertyType(ptf1, tabF);
            //mtF.SetTabOnPropertyType(ptf2, tabF);
            //mtF.SetTabOnPropertyType(ptf3, tabF);
            //mtF.SetTabOnPropertyType(ptf4, tabF);

            mtF.Save();

            //// Add the Silverlight Media
            //MediaType mtS = new MediaType(new Guid("CFBECA90-39A4-4916-813E-3BD5F6F898E4"));
            //PropertyType ptS1 = mtS.AddPropertyType(DataTypeDefinition.GetDataTypeDefinition(new Guid("67DB8357-EF57-493E-91AC-936D305E0F2A")), "ad_integratedCode", "Integrated Code");
            //PropertyType ptS2 = mtS.AddPropertyType(DataTypeDefinition.GetDataTypeDefinition(new Guid("5032A6E6-69E3-491D-BB28-CD31CD11086C")), "ad_thumbnailImage", "Thumbnail Image");
            //PropertyType ptS3 = mtS.AddPropertyType(DataTypeDefinition.GetDataTypeDefinition(new Guid("5032A6E6-69E3-491D-BB28-CD31CD11086C")), "ad_silverlightFile", "Silverlight File");
            //PropertyType ptS4 = mtS.AddPropertyType(DataTypeDefinition.GetDataTypeDefinition(new Guid("EC15C1E5-9D90-422A-AA52-4F7622C63BEA")), "ad_description", "Description");

            //int tabS = mtS.AddVirtualTab("Media");
            //mtS.SetTabOnPropertyType(ptS1, tabS);
            //mtS.SetTabOnPropertyType(ptS2, tabS);
            //mtS.SetTabOnPropertyType(ptS3, tabS);
            //mtS.SetTabOnPropertyType(ptS4, tabS);

            //mtS.Save();

            //// Add the Video Media
            //MediaType mtV = new MediaType(new Guid("AECD70B7-DBD6-49FF-B88B-1EC20FF47744"));
            //PropertyType ptV1= mtV.AddPropertyType(DataTypeDefinition.GetDataTypeDefinition(new Guid("5032A6E6-69E3-491D-BB28-CD31CD11086C")), "ad_mp4Video", "mp4 video");
            //PropertyType ptV2 = mtV.AddPropertyType(DataTypeDefinition.GetDataTypeDefinition(new Guid("5032A6E6-69E3-491D-BB28-CD31CD11086C")), "ad_ogvVideo", "ogv video");
            //PropertyType ptV3 = mtV.AddPropertyType(DataTypeDefinition.GetDataTypeDefinition(new Guid("5032A6E6-69E3-491D-BB28-CD31CD11086C")), "ad_webmVideo", "webm video");
            //PropertyType ptV4 = mtV.AddPropertyType(DataTypeDefinition.GetDataTypeDefinition(new Guid("5032A6E6-69E3-491D-BB28-CD31CD11086C")), "ad_imageThumbail", "Image Thumbnail");
            //PropertyType ptV5 = mtV.AddPropertyType(DataTypeDefinition.GetDataTypeDefinition(new Guid("67DB8357-EF57-493E-91AC-936D305E0F2A")), "ad_integratedCode", "Integrated code");
            //PropertyType ptV6 = mtV.AddPropertyType(DataTypeDefinition.GetDataTypeDefinition(new Guid("EC15C1E5-9D90-422A-AA52-4F7622C63BEA")), "ad_description", "Description");

            //int tabV = mtV.AddVirtualTab("Media");
            //mtV.SetTabOnPropertyType(ptV1, tabV);
            //mtV.SetTabOnPropertyType(ptV2, tabV);
            //mtV.SetTabOnPropertyType(ptV3, tabV);
            //mtV.SetTabOnPropertyType(ptV4, tabV);
            //mtV.SetTabOnPropertyType(ptV5, tabV);
            //mtV.SetTabOnPropertyType(ptV6, tabV);

            //mtV.Save();

            //MediaType mtI = MediaType.GetByAlias("Image");
            //PropertyType ptI1 = mtI.AddPropertyType(DataTypeDefinition.GetDataTypeDefinition(new Guid("EC15C1E5-9D90-422A-AA52-4F7622C63BEA")), "ad_description", "Description");
            //int tabI = mtI.AddVirtualTab("Media");
            //mtI.SetTabOnPropertyType(ptI1, tabI);
            //mtI.Save();

        }


    }

}